package com.wyx.controller.system;

import com.wyx.dto.LoginInfoDto;
import com.wyx.service.LoginInfoService;
import com.wyx.vo.AjaxResult;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;

/**
 * @author xiaoxiong
 * @version 1.0
 * @date 2021/3/6 16:16
 */
@RestController
@RequestMapping("/system/loginInfo")
@Log4j2
public class LoginInfoController {
    @Autowired
    private LoginInfoService loginInfoService;


    @GetMapping("/listForPage")
    public AjaxResult listPage(LoginInfoDto loginInfoDto) {
        return AjaxResult.success(this.loginInfoService.listPage(loginInfoDto));
    }


    @DeleteMapping("/deleteLoginInfoByIds/{infoIds}")
    public AjaxResult deleteByIds(@PathVariable @Validated @NotEmpty(message = "infoIds不能为空") Long[] infoIds){
        return AjaxResult.toAjax(this.loginInfoService.deleteById(infoIds));
    }

    @DeleteMapping("/clearLoginInfo")
    public AjaxResult deleteAll(){
        return AjaxResult.toAjax(this.loginInfoService.deleteAll());
    }

}
